<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('道具表列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <input type="hidden" name="parentId" th:value="${toolId}"/>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "system/courseTool";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "道具表",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                // {
                //     field: 'deleted',
                //     title: '是否删除 0：否，1是'
                // },
                // {
                //     field: 'comment',
                //     title: '道具备注'
                // },
                // {
                //     field: 'count',
                //     title: '道具數量'
                // },
                // {
                //     field: 'imgCount',
                //     title: '道具图片数量'
                // },
                {
                    field: 'title',
                    title: '道具名字'
                },
                {
                    field: 'imgUrl',
                    title: '道具',
                    align: 'center',
                    formatter: function(value, row, index) {
                        if (row.imgUrl != "" && row.imgUrl != null) {
                            if (row.type == 'txt') {
                                return row.imgUrl;
                            }
                            if (row.type == 'image') {
                                return '<img src="' + row.imgUrl + '" height="150" width="150">';
                            }
                            // if (row.type == 'radio'){
                            //     return '<embed height="150" width="100" src="'+row.imgUrl+'">';
                            // }
                            // if (row.type == 'video'){
                            //     return '<video height="150" width="150" controls>  <source src="'+row.imgUrl+'" type="video/mp4"></video>';
                            // }
                            return '<a href="' + row.imgUrl + '">点击查看</a>';
                        }
                    }
                },
                {
                    field: 'cover',
                    title: '封面',
                    align: 'center',
                    formatter: function(value, row, index) {
                        if (row.cover != "" && row.cover != null){
                            if (row.coverType == 'image' || row.coverType == 'txt' ){
                                return '<img src="'+row.cover+'" height="150" width="150">';
                            }
                            return '<a href="'+row.cover+'">点击查看</a>';
                        }
                    }
                },
                // {
                //     field: 'unit',
                //     title: '道具单位'
                // },
                // {
                //     field: 'url',
                //     title: '推荐购买链接'
                // },
                {
                    field: 'ascription',
                    title: '资源归属'
                },
                {
                    field: 'monthAge',
                    title: '月龄阶段'
                },
                {
                    field: 'application',
                    title: '教具应用目标'
                },
                {
                    field: 'applicationType',
                    title: '教具应用使用方式及建议'
                },
                {
                    field: 'comment',
                    title: '标签'
                },
                {
                    field: 'created',
                    title: '创建时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-primary btn-xs  " href="javascript:void(0)" onclick="toolParentList(\'' + row.id + '\')"></i>子列表</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function toolParentList(id) {
        var url = prefix + '/toolParentList?id=' + id;
        $.modal.openTab("子详情列表", url,1200);
    }

</script>
</body>
</html>